#include "QQSettings.h"

QQSettings::QQSettings(QObject* parent)
	: QObject(parent)
{
}

QQSettings::~QQSettings()
{
}

QQSettings* QQSettings::get_instance()
{
	static QQSettings* instance = nullptr;
	if (instance == nullptr)
		instance = new QQSettings(qApp);
	return instance;
}

QString QQSettings::user_data_directory()
{
	static QString data_dir = "";
	if (data_dir.isEmpty()) {
		data_dir = qApp->applicationDirPath() + "/data/";
		if (!QDir(data_dir).exists()) {
			QDir().mkpath(data_dir);
		}
	}
	return data_dir;
}

QString QQSettings::user_download_directory()
{
	static QString system_defualt_download_path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
	if (!QDir(system_defualt_download_path).exists()) {
		QDir().mkpath(system_defualt_download_path);
	}
	return system_defualt_download_path;
}

QString QQSettings::user_image_directory()
{
	return QString();
}

QString QQSettings::user_video_directory()
{
	return QString();
}

QString QQSettings::user_audio_directory()
{
	return QString();
}

QString QQSettings::user_animation_directory()
{
	return QString();
}

QString QQSettings::user_log_directory()
{
	static QString log_dir = "";
	if (log_dir.isEmpty()) {
		log_dir = user_data_directory() + "/log/";
		if (!QDir(log_dir).exists()) {
			QDir().mkpath(log_dir);
		}
	}
	return log_dir;
}

QString QQSettings::user_log_zip_directory()
{
	static QString log_zip_dir = "";
	if (log_zip_dir.isEmpty()) {
		log_zip_dir = user_log_directory() + "/log_zip/";
		if (!QDir(log_zip_dir).exists()) {
			QDir().mkpath(log_zip_dir);
		}
	}
	return log_zip_dir;
}


QString QQSettings::application_shape_library_directory()
{
	return QString();
}

QString QQSettings::application_image_library_directory()
{
	return QString();
}

QString QQSettings::application_applications_library_directory()
{
	return QString();
}

QString QQSettings::application_customization_directory()
{
	return QString();
}

QString QQSettings::application_custom_font_directory()
{
	return QString();
}

QString QQSettings::application_audios_library_directory()
{
	return QString();
}

QString QQSettings::application_videos_library_directory()
{
	return QString();
}

QString QQSettings::application_animations_library_directory()
{
	return QString();
}

QString QQSettings::application_startup_hints_directory()
{
	return QString();
}

QNetworkProxy* QQSettings::http_proxy()
{
	QNetworkProxy* proxy = nullptr;
	proxy = new QNetworkProxy();
	/*proxy->setType(QNetworkProxy::Socks5Proxy);
	proxy->setHostName(mAppSettings->value("Proxy/HostName").toString());
	proxy->setPort(mAppSettings->value("Proxy/Port", 1080).toInt());
	proxy->setUser(mAppSettings->value("Proxy/UserName").toString());
	proxy->setPassword(mAppSettings->value("Proxy/Password").toString());*/
	return proxy;
}